package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.BaseDto;
import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.entity.NursingLevel;
import com.zzyl.mapper.NursingLevelMapper;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description NursingLevelServiceImpl
 * @Author yuan yaming
 * @Date 2024-08-27
 */
@Service
public class NursingLevelServiceImpl implements NursingLevelService {

    @Autowired
    private NursingLevelMapper nursingLevelMapper;

    //查询项目等级
    @Override
    public List<NursingLevelDto> select() {
        return nursingLevelMapper.select();
    }

    //新增护理等级
    @Override
    public void insert(NursingLevelDto nursingLevelDto) {
        NursingLevel nursingLevel = BeanUtil.toBean(nursingLevelDto, NursingLevel.class);
        nursingLevelMapper.insert(nursingLevel);
    }

    //分页查询
    @Override
    public PageResponse<NursingLevelVo> listByPage(String name, Integer status, Integer pageSize, Integer pageNum) {
        PageHelper.startPage(pageNum, pageSize);
        Page<NursingLevelVo> page = nursingLevelMapper.listByPage(name,status);
        PageResponse<NursingLevelVo> pageResponse = new PageResponse(page);
        pageResponse.setRecords(page.getResult());
        return pageResponse;
    }
    //根据ID查询
    @Override
    public NursingLevel getById(Long id) {
        return nursingLevelMapper.getById(id);
    }
    //修改护理等级
    @Override
    public void upDate(NursingLevel nursingLevel) {
        NursingLevel level = BeanUtil.toBean(nursingLevel, NursingLevel.class);
        nursingLevelMapper.upDate(level);
    }
    //删除护理等级
    @Override
    public void delete(Long id) {
        nursingLevelMapper.delete(id);
    }
    //启用禁用
    @Override
    public void onOff(Long id, Integer status) {
        nursingLevelMapper.onOff(id,status);
    }


}
